package com.laihuichuxing.mq.consumerRocket;

import com.alibaba.fastjson.JSON;
import com.laihuichuxing.pool.UserRpPool;
import com.laihuichuxing.pool.entity.UserEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.starter.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.starter.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Description:
 *
 * @author: Qinxuefeng
 * @since: 1.0
 * Create Date Time: 2018/10/11 10:52
 * Update Date Time:
 */
@Slf4j
@Service
@RocketMQMessageListener(topic = "userResourceTopic", consumerGroup = "${spring.rocketmq.userResourceGroup}")
public class UserResourceRConsumer implements RocketMQListener<Map> {
    @Autowired
    private UserRpPool userRpPool;

    @Override
    public void onMessage(Map map) {
        try {
            UserEntity userEntity = JSON.parseObject(JSON.toJSONString(map), UserEntity.class);
           // userRpPool.offer(userEntity);
        } catch (Exception e) {
            log.error("用户资源存储异常:{}",e.getMessage());
        }
    }
}
